package operate

import (
	"context"

	"MBTI/api/internal/svc"
	"MBTI/api/internal/types"
	"MBTI/rpc/admin/adm"

	"github.com/zeromicro/go-zero/core/logx"
)

type SearchResultByStuNoLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewSearchResultByStuNoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SearchResultByStuNoLogic {
	return &SearchResultByStuNoLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *SearchResultByStuNoLogic) SearchResultByStuNo(req *types.SearchResultByStuNoReq) (resp *types.Reply, err error) {
	// todo: add your logic here and delete this line
	searchresp, err := l.svcCtx.AdminRpc.SearchStuByStuNo(l.ctx, &adm.SearchStuByStuNoReq{StudentNo: req.StudentNo})
	if err != nil {
		return nil, err
	}
	return &types.Reply{Code: 100, Data: map[string]interface{}{
		"Result": searchresp.Searchresp,
		"Total":  searchresp.Total,
	}, Msg: "学号查询结果完成！"}, nil
}
